#pragma once
#include <process.h>
#include "ThreadFunction.h"
#include <vector>
#include <map>
using namespace std;
class ThreadPool;


class CSingleLock
{
public:
	CSingleLock() { InitializeCriticalSection(&m_cs);}
	~CSingleLock() { DeleteCriticalSection(&m_cs);}

	void Lock() { EnterCriticalSection(&m_cs);}
	void Unlock() { LeaveCriticalSection(&m_cs);}

protected:
	CRITICAL_SECTION m_cs;
};




class CThread
{
public:
	CThread(void);
	CThread(CThreadFunction *pfun);
	~CThread(void);
public:
	bool Create();
	bool Start();
	virtual void Stop();
	bool IsStoped(){return IsStoped;}
	bool IsAvailable(){return m_bAvailable;}
	bool SetFunction(CThreadFunction *pfun);
private:
	static unsigned __stdcall TREEFUN( void * ptr);
private:
	HANDLE m_hthread;   
	HANDLE m_hEvent;  
	unsigned  int m_thAddr;
	bool m_bStoped;
	bool m_bAvailable;
	CThreadFunction *m_pthFun;
	DWORD m_nSleep;
	 

};
